<?php
declare (strict_types = 1);

namespace app\api\controller;
use app\model\ShopsModel;
use think\App;

class Shops extends Base {

    private $shopsModel;

    private $req;

    private $shop_id;


    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->req = request()->param();

        $this->shop_id = isset($this->req['shop_id']) ? $this->req['shop_id'] : "";

        $this->shopsModel = new ShopsModel();
    }



    public function getShopDetail()
    {
        if(!$this->shop_id){
            return $this->fail("店铺Id 不能为空");
        }

        return $this->succ($this->shopsModel->getInfo($this->shop_id));
    }



    /*
     * 删除指定的类别的缓存
     * */

    public function delCache()
    {
        if(empty($this->req['category_id'])){
            return $this->fail("类别Id 不能为空");
        }

        $res = $this->categoryModel->delCahce($this->req['category_id']);
        return $res ? $this->succ($res,"成功") : $this->fail("失败");
    }



    /*
     * 删除、全部类别的缓存
     * */

    public function delAllCache()
    {
        $res = $this->categoryModel->delAllCache();
        return $res ? $this->succ($res,"成功") : $this->fail("失败");
    }
}
